cmake_minimum_required(VERSION 3.14)
project(TRTorchDemo)

set(CMAKE_CXX_STANDARD 14)

find_package(CUDA 10.2 REQUIRED)
message(STATUS "CUDA library status:")
message(STATUS "    version: ${CUDA_VERSION}")
message(STATUS "    include path: ${CUDA_INCLUDE_DIRS}")
message(STATUS "    libraries: ${CUDA_LIBRARIES}")

find_package(OpenCV 4.4.0 REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

set(CMAKE_PREFIX_PATH /home/developer/zhangcc/myopendatasets/download/centos7/libtorch_gpu)
find_package(Torch 1.8.1 REQUIRED)
if(NOT Torch_FOUND)
    message(FATAL_ERROR "Pytorch Not Found!")
else(NOT Torch_FOUND)
    message(STATUS "Pytorch status:")
    message(STATUS "    version: ${Torch_VERSION}")
    message(STATUS "    libraries: ${TORCH_LIBRARIES}")
    message(STATUS "    include path: ${TORCH_INCLUDE_DIRS}")
endif(NOT Torch_FOUND)

set(TRT_ROOT_DIR /home/developer/zhangcc/myopendatasets/download/centos7/TensorRT-7.2.1.6)
set(TRTorch_ROOT_DIR /home/developer/zhangcc/myopendatasets/download/centos7/TRTorch)
include_directories(${TRT_ROOT_DIR}/include)
include_directories(${TRTorch_ROOT_DIR})
include_directories(${TRTorch_ROOT_DIR}/cpp/api/include)
include_directories(${TORCH_INCLUDE_DIRS})
include_directories(${CUDA_INCLUDE_DIRS})

link_directories(${TRT_ROOT_DIR}/lib)
link_directories(${TRTorch_ROOT_DIR}/build)

cuda_add_executable(main main.cpp trilinear_kernel.cpp)

#target_link_libraries(main ${CUDA_LIBRARIES} ${OpenCV_LIBS} ${TORCH_LIBRARIES}
#                            nvinfer nvinfer_plugin nvonnxparser nvparsers)
target_link_libraries(main ${CUDA_LIBRARIES} ${OpenCV_LIBS} ${TORCH_LIBRARIES}
        trtorch)